import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

import '../config/image_config.dart';
import '../pages/dialog/tip_dialog.dart';
import 'navigator_utils.dart';

class CommonUtil {
  static Future<void> showLocadingDialog(BuildContext context) {
    return NavigatorUtils.showTTDialog(
        context: context,
        builder: (context) {
          return Material(
            color: Colors.transparent,
            child: PopScope(
              canPop: false,
              child: Center(
                child: Container(
                  width: 200,
                  height: 200,
                  padding: const EdgeInsets.all(4),
                  decoration: const BoxDecoration(
                      color: Colors.transparent,
                      borderRadius: BorderRadius.all(Radius.circular(4))),
                  child: Column(
                    mainAxisAlignment: MainAxisAlignment.center,
                    children: [
                      // const SpinKitCubeGrid(color: Color(0xFFFFFFFF),),
                      Container(
                        height: 10,
                      ),
                      // Text("loading....",style: TTStytle.normalTextWhite,)
                      const CircularProgressIndicator(
                        color: Color(0xFFFFFFFF),
                      )
                    ],
                  ),
                ),
              ),
            ),
          );
        });
  }

  static Future<void> showTipDialog(BuildContext context,
      {String? title, String? message,CancelListener? onCancel, ConfirmListener? onConfirm}) {
    return NavigatorUtils.showTTDialog(
        context: context,
        builder: (dialogcontext) {
          return TipDialog(
            title: title ?? "TITLE",
            message: message ?? "MESSAGE",
            onCancel: (){
              if (onCancel != null) {
                onCancel();
              }
            },
            onConfirm: () {
              if (onConfirm != null) {
                onConfirm();
              }
            },
          );
        });
  }
}

typedef ConfirmListener = void Function();
typedef CancelListener = void Function();
